prepare("select * from promoted where(class_id=:a and accademic_year =:b)") ;
$gts->bindparam(":a",$classid) ;
$gts->bindparam(":b",$acyear) ;
$gts->execute() ;
$regnoarray = array() ;
$sname = array() ;
while($row = $gts->fetch(pdo::FETCH_ASSOC))
{
$regnoarray[] = $row['regno'] ;
//
//$rg = $row['stregno'] ;
//$stnames[] = $rg ;
$getname = $DBcon->prepare("select * from students_info where (regno =:r)") ;
$getname->bindparam(":r",$row['regno']) ;
$getname->execute() ;
$rown = $getname->fetch(pdo::FETCH_ASSOC) ;
$fulname = $rown['fullname'] ;
//$md = $rown['middlename'] ;
//$ln = $rown['lastname'] ;
//$fulname = $fn.' '.$md.' '.$ln;
//
$sname[] = $fulname ;
}
$lenght = count($regnoarray) ;
if (array_key_exists('submit', $_POST))
{
$subj = trim($_POST['subject']) ;
$getsid = $DBcon->prepare("select subject_id from subjects where subjectname = '$subj'") ;
$getsid->execute() ;
$gw = $getsid->fetch(pdo::FETCH_ASSOC) ;
$subjid = $gw['subject_id'] ;
//check if subjects has been uploaded before
$check = $DBcon->prepare("select * from marks where( (acyear = '$acyear' and subject_id = $subjid) and (term = '$schterm' and klass = '$classid'))") ;
$check->execute() ;
if($check->rowcount() > 0)
{
$msg = $subj.' '."Has been uploaded before" ;
}
else
{
for($x = 0; $x < $lenght; $x++)
{
//echo "value : ".$value.'
';
$reg = $regnoarray[$x] ;
$test = $_POST['test'][$x] ;
$exam = $_POST['exam'][$x] ;
if(empty($test)) $test = 0;
if(empty($exam)) $exam = 0;
if(($test == 0) and ($exam == 0))
{
//do nothing
}
else
{
$sql = $DBcon->prepare("insert into marks(acyear,term,klass,subject,subject_id,regno,level,test,exam,admin) values(:a,:b,:c,:d,:e,:f,:g,:h,:i,:j)");
$sql->bindparam(":a",$acyear) ;
$sql->bindparam(":b",$schterm) ;
$sql->bindparam(":c",$classid) ;
$sql->bindparam(":d",$subj) ;
$sql->bindparam(":e",$subjid) ;
$sql->bindparam(":f",$reg) ;
$sql->bindparam(":g",$lv) ;
$sql->bindparam(":h",$test) ;
$sql->bindparam(":i",$exam) ;
$sql->bindparam(":j",$admin) ;
if($sql->execute()) $msg = $subj .' '.'Published succesfully' ;
}
}
}
}
?>